// MProgram.cpp : Implementation of CMudosApp and DLL registration.

#include "stdafx.h"
#include "m.h"

/////////////////////////////////////////////////////////////////////////////
//

STDMETHODIMP CMProgram::InterfaceSupportsErrorInfo(REFIID riid)
{
	static const IID* arr[] = 
	{
		&IID_IMProgram,
	};

	for (int i=0;i<sizeof(arr)/sizeof(arr[0]);i++)
	{
		if (InlineIsEqualGUID(*arr[i],riid))
			return S_OK;
	}
	return S_FALSE;
}

STDMETHODIMP CMProgram::get_FunctionCount(int * pVal)
{
	// TODO: Add your implementation code here
	if(!pVal)return S_FALSE;
	*pVal=GetProg()->num_functions_total;
	return S_OK;
}

STDMETHODIMP CMProgram::get_Function(int id, IMFunction * * pVal)
{
	// TODO: Add your implementation code here
	if(!pVal)return S_FALSE;
	if((id<0)||(id>=GetProg()->num_functions_total))return S_FALSE;

	CComObject<CMFunction> *f;
	f=new CComObject<CMFunction>;
	f->AddRef();
	f->Create(this,id);
	*pVal=f;
	return S_OK;
}

STDMETHODIMP CMProgram::get_FileName(BSTR * pVal)
{
	// TODO: Add your implementation code here
	if(!pVal)return S_FALSE;
	Cc2w c2w;
	c2w.in(GetProg()->name);
	*pVal=SysAllocString(c2w.out());
	return S_OK;
}


